home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / ste / autoexec.lzh / SOURCE / TINYSTRT.S < prev   
Text File  |  1991-08-05  |  3KB  |  102 lines

  1. *    TINYSTART is written by Klaus Pedersen (micro@imada.dk), and
  2. *    distributed, together with "NT_COMP" - the NoiseTracker Compiler
  3. *    for Atari [MEGA] ST, STe and TT computers.
  4. *   Based on Borland's and Atari's (Ken B.) startup code.
  5.     
  6.                 IMPORT main
  7.  
  8.                 GLOBL _BasPag
  9.                 GLOBL _app
  10.                 GLOBL _PgmSize
  11.                 GLOBL __text, __data, __bss
  12.  
  13.                 GLOBL exit, errno ; these make TC stdio happy!
  14.  
  15. TextStart       EQU $08 
  16. TextSize        EQU $0C 
  17. DataStart       EQU $10 
  18. DataSize        EQU $14
  19. BssStart        EQU $18
  20. BssSize         EQU $1C 
  21. CmdLine         EQU $80
  22.  
  23.  
  24. * Text segment...
  25.                 TEXT
  26.  
  27. __text:         moveq   #0,D1
  28.                 move.l  A0,D0
  29.                 bne.b   NotApp
  30.                 moveq   #1,D1
  31.                 movea.l 4(SP),A0
  32.  
  33. NotApp:         move.l  A0,_BasPag
  34.                 move.w  D1,_app
  35.  
  36. * Calculate program size...
  37.                 movea.l TextSize(A0),A1
  38.                 adda.l  DataSize(A0),A1
  39.                 adda.l  BssSize(A0),A1
  40.                 adda.w  #$100,A1
  41.                 move.l  A1,_PgmSize
  42.  
  43. * Set stack at top of BSS...
  44.                 move.l  A0,D0
  45.                 add.l   A1,D0
  46.                 and.b   #$FC,D0
  47.                 movea.l D0,SP
  48.                 tst.w   _app
  49.                 beq.b   EmptyCommand  ; No environment and no arguments
  50.  
  51. * Make A3 point to Command line...
  52.                 lea     CmdLine(A0),A3
  53.  
  54. * Shrink memory...
  55.                 move.l  A1,-(SP)
  56.                 move.l  A0,-(SP)
  57.                 move.l  #$4A0000,-(SP)
  58.                 trap    #1
  59.                 lea     12(SP),SP
  60.  
  61. * Pass command Line...
  62.                 moveq   #0,D0
  63.                 move.b  (A3)+,D0   ; anything in command-line?
  64.                 beq.b   EmptyCommand
  65.                 clr.b   0(A3,D0.w) ; terminate command-line
  66.                 lea     ArgPointer,A0 ; Argument array (2 long)
  67.                 move.l  A3,4(A0)   ; write address of command line
  68.                 moveq   #2,D0      ; set argc.
  69.  
  70. EmptyCommand:
  71.  
  72. * Execute main program...
  73. *   D0 = argc, if (argc<2) then no parameter(s)...
  74. *   A0 = *argv[2], argv[0] is dummy, argv[1] is a pointer to the command
  75. *        null terminated commandline...
  76. *   In non TURBO_C env. pass these on the stack...
  77.  
  78.                 bsr     main
  79.  
  80. exit:           move.w  D0,-(SP)
  81.                 move.w  #$4C,-(SP)
  82.                 trap    #1
  83.  
  84.  
  85. * Initialized data segment...
  86.                 DATA
  87. __data:
  88.  
  89. errno:          DC.W 0             ; needed to keep stdio happy!
  90.  
  91. * Variable segment...
  92.                 BSS
  93. __bss:
  94.  
  95. _BasPag:        DS.L 1
  96. _PgmSize:       DS.L 1
  97. _app:           DS.W 1
  98.  
  99. ArgPointer:     DS.L 2             ; only 2 args is used (a null and 1.)
  100.  
  101.                 END
  102.